package com.lagou.edu.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import com.lagou.edu.dao.UserDao;
import com.lagou.edu.pojo.LagouToken;
import com.lagou.edu.service.UserService;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Override
    public LagouToken saveToken(String email,String password) {
        LagouToken lagouToken = new LagouToken();
        lagouToken.setEmail(email);
        lagouToken.setToken(email+"_"+password);
        return userDao.save(lagouToken);
    }

  @Override
  public LagouToken findOne(String token) {
    LagouToken lagouToken = new LagouToken();
    lagouToken.setToken(token);
    Example<LagouToken> example = Example.of(lagouToken);
    return userDao.findOne(example).get();
  }
}
